<?php
namespace app\home\controller;

use app\BaseController;
use think\facade\Db;
use PhpOffice\PhpSpreadsheet\IOFactory;
class Index extends BaseController
{
    public function index() {
    	$nowTime = date('Y-m-d H:i:s',time());
    	$data = Db::table('yhq_tickets')->field('id,goods_name,img_url,price,ticket_price,ticket_command')->where('ticket_end_time','>=',$nowTime)->order('id desc')->paginate(10);
        return $data;       
    }

    public function detail() {
    	$result = array();
    	if(isset($_GET['id'])) {
    		$data = Db::table('yhq_tickets')->where(array('id' => $_GET['id']))->find();
    		if(empty($data)) {
    			$result['success'] = false;
    			$result['message'] = '数据不存在';
    		} else {
    			$result['success'] = true;
    			$result['data'] = $data;
    		}
    	} else {
    		$result['success'] = false;
    		$result['message'] = '参数有误';
    	}	
        return $result;		
    }
}